package com.jinmdz.fmis.mapper.mapper;

import org.apache.ibatis.annotations.*;
import com.jinmdz.fmis.mapper.mapper.provider.LoungeProvider;
import com.jinmdz.fmis.mapper.entity.LoungeEntity;

import java.util.ArrayList;

/**
 * 休息室预约表Mapper
 * 
 * @author generator
 * @date 2020-08-23 18:11
 */
public interface LoungeMapper {

    /**
     * 增加Lounge
     * 
     * @param entity 数据实体
     * @return
     * @author generator
     * @date 2020-08-23 18:11
     */
    @InsertProvider(type = LoungeProvider.class, method = "insertLounge")
    @Options(useGeneratedKeys = true, keyProperty = "entity.id", keyColumn = "id")
    void insertLounge(@Param("entity") LoungeEntity entity);

    /**
     * 删除Lounge
     * 
     * @param id 主键
     * @param modifiedUserId 修改用户外键
     * @param version 版本号
     * @return
     * @author generator
     * @date 2020-08-23 18:11
     */
    @Update(" update lounge set deleted = 1,modified_user_id = #{modifiedUserId},version = unix_timestamp(now()) where id = #{id} and version = #{version} and unmodified = 0 and deleted = 0 ")
    void deletedForLounge(@Param("id") Integer id, @Param("modifiedUserId") Integer modifiedUserId, @Param("version") Long version);

    /**
     * 修改Lounge
     * 
     * @param entity 数据实体
     * @return
     * @author generator
     * @date 2020-08-23 18:11
     */
    @UpdateProvider(type = LoungeProvider.class, method = "updateLounge")
    void updateLounge(@Param("entity") LoungeEntity entity);

    /**
     * 查询Lounge实体
     * 
     * @param id 主键
     * @return LoungeEntity
     * @author generator
     * @date 2020-08-23 18:11
     */
    @Select(" select id,deleted,business_code,home_type_code,home_id,appointment_in_time,appointment_out_time,reality_in_time,reality_out_time,process_state_code,rule_number,rule_unit,rule_code,rule_remark,remark,random_code,charge_id,funeral_parlour_code,create_user_id,gmt_create,unmodified,modified_user_id,gmt_modified,version from lounge where id = #{id} and deleted = 0 limit 1 ")
    LoungeEntity getLoungeById(@Param("id") Integer id);

    /**
     * 查询Lounge列表
     * 
     * @param entity 数据实体
     * @return LoungeEntity
     * @author generator
     * @date 2020-08-23 18:11
     */
    @SelectProvider(type = LoungeProvider.class, method = "listLounge")
    ArrayList<LoungeEntity> listLounge(@Param("entity") LoungeEntity entity);
}